<template>
    <div style="height:100%;width:100%;position:relative;" ref="maindev">
        <div class="pagetop" :style="{ height: OtherShow?'288px':'68px' }" v-show="show_sel">
            <!-- height 32px 13 67%-->
            <table style="width: 100%; font-size: 12px;" border="0">
                <col style="width: 4%;" />
                <col style="width: 7%;" />
                <col style="width: 1%;" />
                <col style="width: 7%;" />
                <col style="width: 4%;" />
                <col style="width: 10%;" />
                <col style="width: 4%;" />
                <col style="width: 11%;" />
                <col style="width: 4%;" />
                <col style="width: 10%;" />
                <col style="width: 4%;" />
                <col style="width: 15%;" />
                <col style="width: 20%;" />
                <tr>
                    <td>标本日期</td>
                    <td>
                        <el-date-picker v-model="sample_startdt" :able="false" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;min-width: 100px;" :picker-options="pickerOptions" :clearable="false" :key="startkey">
                        </el-date-picker>
                    </td>
                    <td align="center">至</td>
                    <td>
                        <el-date-picker v-model="sample_enddt" type="date" :able="false" placeholder="选择日期" value-format="yyyy-MM-dd" style="width: 100%;min-width: 100px;" :picker-options="pickerOptions" :clearable="false" :key="endkey">
                        </el-date-picker>
                    </td>
                    <td>报告单元</td>
                    <td>
                        <rm-ddl-rptunit prgno="LIS481" v-model="sel_rptunit" width="100%" clearable></rm-ddl-rptunit>
                    </td>
                    <td style="font-width: blod">{{Qna}}</td>
                    <td colspan="3">
                        <el-input size="small" style="width:calc(100% - 70px);" v-model="quicklyQ" :placeholder="currholder" ref="refQuicklyQ" @focus="Focus($event)" @keyup.enter.native="BtnQuery"></el-input>
                        <el-checkbox v-model="sel_qna_mh" true-label="1" false-label="0" style="padding-left:5px;width:70px" @focus="Focus($event)" @change="ChangeQ">姓名模糊</el-checkbox>
                    </td>
                    <td>业务类型</td>
                    <td>
                        <div>
                            <el-radio-group v-model="sel_reqtype" size="mini">
                                <el-radio label="">全部</el-radio>
                                <el-radio label="C">检验</el-radio>
                                <el-radio label="H">输血</el-radio>
                            </el-radio-group>
                        </div>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>条码号</td>
                    <td colspan="3">
                        <el-input size="small" style="width:100%;" v-model="sel_barcode"></el-input>
                    </td>
                    <td>病历号</td>
                    <td>
                        <el-input size="small" style="width:100%;min-width:130px" v-model="sel_patno" clearable @focus="Focus($event)"></el-input>
                    </td>
                    <td>姓名</td>
                    <td>
                        <el-input size="small" style="width:calc( 100% - 60px );" v-model="sel_patname"></el-input> &nbsp;
                        <el-checkbox v-model="sel_patname_mh" @focus="Focus($event)">模糊</el-checkbox>
                    </td>
                    <td>病人类型</td>
                    <td>
                        <el-select v-model="sel_pattypecode" @dblclick.native="popMultipleChk(sel_pattypecode,'sel_pattypecode',pattypeOption,'病人类型选择')" filterable clearable style="width:100%">
                            <el-option v-for="(item,index) in pattypeOption" :value="item.data" :label="item.display" :key="index"></el-option>
                        </el-select>
                    </td>
                    <td>病人床号</td>
                    <td>
                        <el-input size="small" style="width:100%;min-width:130px" v-model="sel_reqbedno" @focus="Focus($event)"></el-input>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>样本号</td>
                    <td colspan="3">
                        <el-input size="small" style="width:100%;" placeholder="输入如1,2,5-8等格式" v-model="sel_sampleno" @focus="Focus($event)"></el-input>
                    </td>

                    <td>病人卡号</td>
                    <td>
                        <el-input size="small" style="width:100%;" v-model="sel_patcardno" @focus="Focus($event)"></el-input>
                    </td>
                    <td>自动审核</td>
                    <td>
                        <el-select v-model="sel_chkflag" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="待审核" value="0"></el-option>
                            <el-option key="1" label="审核通过" value="1"></el-option>
                            <el-option key="2" label="审核不通过" value="2"></el-option>
                            <el-option key="9" label="不参与审核" value="9"></el-option>
                        </el-select>
                    </td>
                    <td>送检医院</td>
                    <td>
                        <rm-ddl-common datatype="hospital" dataname="医院" v-model="sel_hospitalcode" width="100%"></rm-ddl-common>
                    </td>
                    <td>审核状态</td>
                    <td>
                        <el-select v-model="sel_ischeck" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="未审核" value="0"></el-option>
                            <el-option key="1" label="已审核" value="1"></el-option>
                        </el-select>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>报告项目</td>
                    <td colspan="3">
                        <rm-ddl-rptitem prgno="LIS481" isAllRpt="1" v-model="sel_rptitemcode" width="100%" :appendtobody="true"></rm-ddl-rptitem>
                    </td>
                    <td>申请科室</td>
                    <td>
                        <rm-ddl-common datatype="dept" dataname="科室" v-model="sel_reqdeptno" width="100%"></rm-ddl-common>
                    </td>
                    <td>申请医生</td>
                    <td>
                        <rm-ddl-common datatype="doctor" dataname="送检医生" v-model="sel_reqdocno" width="100%"></rm-ddl-common>
                    </td>
                    <td>标本状态</td>
                    <td>
                        <el-select v-model="sel_specimencomm" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="无标记" value="0"></el-option>
                            <el-option key="1" label="有标记" value="1"></el-option>
                        </el-select>
                    </td>
                    <td>采样医生</td>
                    <td>
                        <rm-ddl-common datatype="userinfo" dataname="用户" v-model="sel_sampleduser" width="100%"></rm-ddl-common>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>送检目的</td>
                    <td colspan="3">
                        <el-input size="small" style="width:100%;" v-model="sel_reqreason"></el-input>
                    </td>
                    <td>耐药机制</td>
                    <td>
                        <el-select v-model="sel_result4" @dblclick.native="popMultipleChk(sel_result4,'sel_result4',rescodeOption,'耐药机制选择')" filterable clearable style="width:100%">
                            <el-option v-for="(item,index) in rescodeOption" :value="item.data" :label="item.display" :key="index"></el-option>
                        </el-select>
                    </td>
                    <td>结果标志</td>
                    <td>
                        <el-select v-model="sel_rflag" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="异常" value="0"></el-option>
                            <el-option key="1" label="正常" value="1"></el-option>
                        </el-select>
                    </td>
                    <td>标本类型</td>
                    <td>
                        <rm-ddl-common ref="ddlspecimen" datatype="specimen" dataname="标本类型" v-model="sel_specimencode" width="100%"></rm-ddl-common>
                    </td>
                    <td>
                        收费类别
                    </td>
                    <td>
                        <rm-ddl-common datatype="chargetype" dataname="收费类别" v-model="sel_chargetypeno" width="100%"></rm-ddl-common>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>临床诊断</td>
                    <td colspan="3">
                        <el-input size="small" style="width:100%;" v-model="sel_patdiag"></el-input>
                    </td>
                    <td>检验医生</td>
                    <td>
                        <rm-ddl-common datatype="userinfo" dataname="用户" v-model="sel_reportuser" width="100%"></rm-ddl-common>
                    </td>
                    <td>所属病区</td>
                    <td>
                        <rm-ddl-common :appendtobody="true" datatype="ward" dataname="病区" v-model="sel_reqwardno" width="100%"></rm-ddl-common>
                    </td>
                    <td>病人所属医院</td>
                    <td>
                        <rm-ddl-common datatype="hospital" dataname="医院" v-model="sel_pat_hospcode" width="100%"></rm-ddl-common>
                    </td>
                    <td>急诊标志</td>
                    <td>
                        <el-select v-model="sel_emerflag" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="常规" value="0"></el-option>
                            <el-option key="1" label="加急" value="1"></el-option>
                        </el-select>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>身份证号</td>
                    <td colspan="3">
                        <el-input size="small" style="width:100%;" v-model="sel_pat_idcardno" @focus="Focus($event)"></el-input>
                    </td>
                    <td>审核医生</td>
                    <td>
                        <rm-ddl-common datatype="userinfo" dataname="用户" v-model="sel_rechkuser" width="100%"></rm-ddl-common>
                    </td>
                    <td>病区组</td>
                    <td>
                        <rm-ddl-common :appendtobody="true" datatype="wardcomb" dataname="病区" v-model="sel_combno" width="100%"></rm-ddl-common>
                    </td>
                    <td>打印状态</td>
                    <td>
                        <el-select v-model="sel_isprint" placeholder="请选择" style="width:100%">
                            <el-option key="all" label="全部" value="all"></el-option>
                            <el-option key="0" label="未打印" value="0"></el-option>
                            <el-option key="1" label="已打印" value="1"></el-option>
                        </el-select>
                    </td>
                    <!-- <td>文字结论</td>
                    <td>
                        <el-input size="small" style="width:100%;" v-model="sel_txtinfo2"></el-input>
                    </td> -->
                    <td>备注</td>
                    <td>
                        <rm-ddl-common datatype="seccode" kindno="REPORTCOMM" dataname="备注" v-model="sel_reportcomm" width="100%"></rm-ddl-common>
                    </td>
                </tr>
                <tr v-show="OtherShow">
                    <td>报告单元多选</td>
                    <td colspan="3">
                        <rm-ddl-rptunit prgno="LIS481" :multiple_choice="true" v-model="sel_rptunitlist" clearable width="100%"></rm-ddl-rptunit>
                    </td>
                    <td>报告项目组合</td>
                    <td>
                        <rm-ddl-common datatype="reportitemcomb" dataname="项目组合" v-model="sel_itemcombid" width="100%"></rm-ddl-common>
                    </td>
                    <td>混样报告</td>
                    <td>
                        <el-select v-model="sel_mixrpt" placeholder="请选择" style="width:100%">
                            <el-option key="0" label="全部报告" value="0"></el-option>
                            <el-option key="1" label="混样主报告" value="1"></el-option>
                            <el-option key="2" label="混样明细报告" value="2"></el-option>
                        </el-select>
                    </td>
                    <td>
                        <el-popover placement="bottom-end" width="150" trigger="click">
                            <el-checkbox v-model="sel_outsex">剔除无性别</el-checkbox>
                            <el-checkbox v-model="sel_markno">仅标记的报告 </el-checkbox>
                            <el-checkbox v-model="sel_onlyouthospital">仅查询外院</el-checkbox>
                            <el-checkbox v-model="sel_onlymed">仅显示细菌阳性结果 </el-checkbox>
                            <el-checkbox v-model="sel_onlylast">仅显示最终报告结果 </el-checkbox>
                            <el-link type="primary" :underline="true" style="font-size: 12px;" slot="reference">{{ "其余选项" }}</el-link>
                        </el-popover>
                    </td>
                    <!-- <td colspan="4" align="left">

                        <el-checkbox v-model="sel_outsex">剔除无性别</el-checkbox>
                        <el-checkbox v-model="sel_markno">仅标记的报告 </el-checkbox>
                        <el-checkbox v-model="sel_onlyouthospital">仅查询外院</el-checkbox>
                        <el-checkbox v-model="sel_onlymed">仅显示细菌阳性结果 </el-checkbox>
                    </td> -->
                    <td colspan="5"></td>
                </tr>
                <tr>
                    <td colspan="13" align="right">
                        <el-link :underline="false" @click="BtnOtherShow">{{OtherShow?"收起▲":"展开▼"}}</el-link>
                        <el-button icon="el-icon-search" type="primary" @click="BtnQuery">查询(F8)</el-button>
                        <el-button icon="el-icon-delete" @click="BtnClear">清除</el-button>
                        <!-- <el-button icon="el-icon-aim" @click="BtnCheckRef">校验参考值</el-button> -->
                        <el-button v-has="'PPRINT'" @click.native="BtnPrint" icon="el-icon-printer">打印</el-button>
                        <!-- 打印功能集中选中行打印和勾选打印-->
                        <!-- <el-button @click.native="BtnBatchPrint" icon="el-icon-printer">打印勾选</el-button> -->
                        <el-button v-has="'PPRINT'" @click.native="BtnPreView" icon="el-icon-zoom-in">预览</el-button>
                        <!-- <el-button v-has="'PEXPORT'" @click.native="BtnExport" icon="el-icon-zoom-in">PDF导出</el-button> -->
                        <!-- <el-button v-has="'PPRINT'" @click.native="BtnAutoPrint" icon="el-icon-printer">自助测试</el-button> -->
                        <el-button v-has="'PEXPORT'" @click.native="BtnExcelExport" icon="el-icon-download">导出</el-button>
                        <el-button v-has="'PVIEWCASE'" icon="el-icon-notebook-2" @click="QueryPatcase">查阅病历</el-button>
                    </td>
                </tr>
            </table>
        </div>
        <div class="pagecenter" :style="{ top: OtherShow?'293px':'74px'}">
            <!-- <div :style="middle_center"> -->
            <el-tabs style="height:100%;" type="border-card" v-model="tab_showflag" @tab-click="tabclick_Event">
                <el-tab-pane label="报告单" name="tab_report">
                    <rm-layout-right splitcolor="#ffffff" :splitwidth="2" :fixsize="475" :minfixsize="200" ref="layoutright">
                        <vxe-table :data.sync="report_data" :loading="report_Loading" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="auto" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="reportTable" resizable show-overflow size="mini" :row-class-name="reportRowName" show-header-overflow :optimization="{animat: false}" @current-change="reportchange_Event" :cell-class-name="reportCellName" @cell-dblclick="cellDblClickEvent" header-align="center">
                            <!-- @cell-click="cellClickEvent"  -->
                            <vxe-table-column field="alter_flag" sortable title="危" width="20" show-overflow align="center">
                                <template v-slot="{ row, rowIndex, columnIndex }">
                                    <div :key="row.userno+rowIndex+columnIndex" v-if="row.alter_flag == '1'||row.alter_flag=='2'">
                                        <font color="#000000">危</font>
                                    </div>
                                    <div :key="row.userno+rowIndex+columnIndex" v-else>
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="emer_flag" sortable title="急" width="20" show-overflow align="center">
                                <template v-slot="{ row, rowIndex, columnIndex }">
                                    <div :key="row.userno+rowIndex+columnIndex" v-if="row.emer_flag == '1'">
                                        <font color="red">急</font>
                                    </div>
                                    <div :key="row.userno+rowIndex+columnIndex" v-else>
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="redo_flag" sortable title="复" width="20" show-overflow align="center">
                                <template v-slot="{ row, rowIndex, columnIndex }">
                                    <div :key="row.userno+rowIndex+columnIndex" v-if="row.redo_flag =='2' || row.redo_flag=='3'">
                                        <font color="#000000">复</font>
                                    </div>
                                    <div :key="row.userno+rowIndex+columnIndex" v-else>
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="rechkflag" sortable title="审" width="20" show-overflow align="center">
                                <template v-slot="{ row, rowIndex, columnIndex }">
                                    <div :key="row.userno+rowIndex+columnIndex" v-if="row.rechkflag == '9'">
                                        <font color="#000000">审</font>
                                    </div>
                                    <div :key="row.userno+rowIndex+columnIndex" v-else>
                                    </div>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="rptunitname" sortable title="报告单元" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column align="center" field="sampledate" sortable title="标本日期" width="70" :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                            <vxe-table-column field="sampleno" align="center" sortable title="标本号" width="60" show-overflow :sort-width="20"></vxe-table-column>
                            <!-- 添加打印选择-->
                            <vxe-table-column field="cp_selection" title="选择" width="40px" align="center">
                                <template v-slot:header="{ column }">
                                    <el-checkbox v-model="selectall" @change="ChkAll($event)"></el-checkbox>
                                </template>
                                <template v-slot="{ row, rowIndex }">
                                    <el-checkbox v-model="row.cp_selection" true-label="1" false-label="0" @change="handleCheckedPrintChange(row, rowIndex)"></el-checkbox>
                                </template>
                            </vxe-table-column>
                            <vxe-table-column field="pat_name" align="center" sortable title="病人姓名" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_no" sortable title="病人号" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="log_date" align="center" sortable title="解审时间" width="120" show-overflow></vxe-table-column>
                            <vxe-table-column field="log_user" align="center" sortable title="解审医生" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="log_content" header-align="center" text-align="left" sortable title="解审原因" width="240" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_sexname" align="center" sortable title="性别" width="35" show-overflow></vxe-table-column>
                            <vxe-table-column field="rechk_dt" align="center" sortable title="审核时间" width="120" show-overflow></vxe-table-column>
                            <vxe-table-column field="rechk_user" align="center" sortable title="审核医生" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_reason" sortable title="送检目的" width="400" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_agestr" align="center" sortable title="年龄" width="40" show-overflow></vxe-table-column>
                            <vxe-table-column field="specimen" sortable title="标本类型" width="90" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_bedno" align="center" sortable title="床号" width="50" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_typecodename" align="center" sortable title="病人类别" width="80" show-overflow></vxe-table-column>
                            <vxe-table-column field="barcode" sortable title="条码号" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_dept" sortable title="申请科室" width="150" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_ward" sortable title="病人病区" width="120" show-overflow></vxe-table-column>
                            <vxe-table-column field="charge_typeno" align="center" sortable title="收费类别" width="90" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_diag" sortable title="临床诊断" width="250" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="req_doc" align="center" sortable title="申请医生" width="70" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_cardno" sortable title="就诊卡号" width="110" show-overflow></vxe-table-column>
                            <vxe-table-column field="inp_id" sortable title="就诊号" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="recieve_dt" align="center" sortable title="接收时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="input_dt" align="center" sortable title="录入时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="test_info" sortable title="上机信息" width="120" show-overflow></vxe-table-column>
                            <vxe-table-column field="test_dt" align="center" sortable title="上机时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="report_dt" align="center" sortable title="报告时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="report_user" align="center" sortable title="检验医生" width="70" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_id" sortable title="病人ID" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="report_comm" sortable title="报告单备注" width="150" show-overflow></vxe-table-column>
                            <vxe-table-column field="lab_advice" sortable title="实验室意见" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="item_num" align="center" sortable title="项目数" width="50" show-overflow></vxe-table-column>
                            <vxe-table-column field="instr_advice" sortable title="仪器辅助诊断" width="150" show-overflow></vxe-table-column>
                            <vxe-table-column field="rechk2_dt" align="center" sortable title="二审时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="rechk2_user" align="center" sortable title="二审医生" width="70" show-overflow></vxe-table-column>
                            <vxe-table-column field="lastprint_dt" align="center" sortable title="最后打印时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_birth" align="center" sortable title="病人生日" width="90" :formatter="['toDateString', 'yyyy-MM-dd']" show-overflow></vxe-table-column>
                            <vxe-table-column field="prereport_dt" align="center" sortable title="预计报告时间" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="reportid" sortable title="报告ID" width="160" show-overflow></vxe-table-column>
                            <vxe-table-column field="hospcode" sortable title="送检医院" width="180" show-overflow></vxe-table-column>
                            <vxe-table-column field="inp_date" align="center" sortable title="入院日期" width="140" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_phone" sortable title="联系电话" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="release_user" align="center" sortable title="发布人" width="70" show-overflow></vxe-table-column>
                            <vxe-table-column field="is_changed" align="center" sortable title="是否修改" width="70" show-overflow></vxe-table-column>
                            <vxe-table-column field="changed_afterreport" align="center" sortable title="打印、审核后修改" width="130" show-overflow></vxe-table-column>
                            <vxe-table-column field="unprint_flag" align="center" sortable title="禁止打印标志" width="100" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_diag_icd" sortable title="临床诊断标准码" width="160" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_address" sortable title="病人地址" width="200" show-overflow></vxe-table-column>
                            <vxe-table-column field="pat_idcardno" align="center" sortable title="身份证/护照号" width="200" show-overflow></vxe-table-column>
                            <vxe-table-column field="print_count" align="center" sortable title="打印次数" width="60" show-overflow></vxe-table-column>
                            <vxe-table-column field="unprint_reason" sortable title="禁止打印原因" width="120" show-overflow></vxe-table-column>
                         
                        </vxe-table>
                        <div class="fixtotal">
                            <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span style="color:red;margin-left:10px;float:right;">合计: {{rpt_amount}}</span>
                                    <div style="clear:both"></div>
                                </div>
                            </div>
                        <template v-slot:fix>
                            <div v-if="is_ym" class="right-inser">
                                <div class="middle-tab-top">
                                    <vxe-table :data.sync="result_data" :loading="result_Loading" header-align="center" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="200px" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="ymresulttable" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{animat: false}">
                                        <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result_str" sortable title="检测结果" width="80" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result1" sortable title="菌落计数" width="150" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result4" sortable title="耐药机制" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="instrna" sortable title="检验仪器" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="interno" sortable title="通道号" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="redo_result" sortable title="复查前结果" width="80" show-overflow></vxe-table-column>
                                        <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="150" show-overflow></vxe-table-column>
                                        <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="150" show-overflow></vxe-table-column>
                                        <vxe-table-column field="modify_flag" sortable title="修改标志" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="first_dt" align="center" sortable title="第一次填入时间" width="120" show-overflow></vxe-table-column>
                                        <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120" show-overflow></vxe-table-column>
                                        <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80" show-overflow></vxe-table-column>
                                        <vxe-table-column field="rptunitid" sortable title="报告单元" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="60" show-overflow></vxe-table-column>
                                    </vxe-table>
                                    <div class="fixtotal">
                                        <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span style="color:red;margin-left:10px;float:right;">合计: {{result_amount}}</span>
                                                <div style="clear:both"></div>
                                            </div>
                                        </div>
                                </div>
                                <div class="middle-tab-bottom">
                                    <vxe-table :data.sync="resusltmed_date" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border header-align="center" :height="ymresultheight" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="ymresulttable2" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{animat: false}">
                                        <vxe-table-column field="medname" sortable title="抗生素" width="220" show-overflow></vxe-table-column>
                                        <vxe-table-column field="medresult" sortable title="药敏结果" header-align="center" align="center" width="60" show-overflow>
                                            <template v-slot="{ row }">
                                                <div :style="{background: row.cp_resultbackgroundcolor,color: row.cp_resultcolor}" style="padding:0px 10px">
                                                    {{ row.medresult }}
                                                </div>
                                            </template>
                                        </vxe-table-column>
                                        <vxe-table-column field="rad" sortable title="Rad" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="mic" sortable title="Mic" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result_flag" align="center" sortable title="标志" width="60" show-overflow></vxe-table-column>
                                        <vxe-table-column field="result6" sortable title="参考范围" width="120" show-overflow></vxe-table-column>
                                        <vxe-table-column field="expertresult" sortable title="专家值" width="100" show-overflow></vxe-table-column>
                                        <vxe-table-column field="medgroup" align="center" sortable title="分组" width="80" show-overflow></vxe-table-column>
                                    </vxe-table>
                                    <div class="fixtotal">
                                        <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span style="color:red;margin-left:10px;float:right;">合计:
                                                    {{ymresultitem_amount}}</span>
                                                <div style="clear:both"></div>
                                            </div>
                                        </div>
                                </div>
                            </div>
                            <div v-if="!is_ym" class="right-inser">
                                <vxe-table :data.sync="result_data" :loading="result_Loading" header-align="center" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border :height="resultheight" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="ymresulttable" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{animat: false}">
                                    <vxe-table-column field="rpt_itemname" sortable title="检验项目" width="220" show-overflow> <template v-slot="{ row }">
                                            <div v-if="row.alertflag == '1'" style="background:red;padding:0px 10px">
                                                {{ row.rpt_itemname }}
                                            </div>
                                            <div v-else style="padding:0px 10px">
                                                {{ row.rpt_itemname }}
                                            </div>
                                        </template></vxe-table-column>
                                    <vxe-table-column field="result_str" sortable title="检测结果" width="80" show-overflow> <template v-slot="{ row }">
                                            <div :style="{
                            background: row.cp_resultbackgroundcolor,
                            color: row.cp_resultcolor
                          }" style="padding:0px 10px">
                                                {{ row.result_str }}
                                            </div>
                                        </template></vxe-table-column>
                                    <vxe-table-column field="result_unit" sortable title="单位" width="70" show-overflow></vxe-table-column>
                                    <vxe-table-column field="result_ref" sortable title="参考值" width="100" show-overflow></vxe-table-column>
                                    <vxe-table-column field="result1" :title="result1text" width="70px" v-if="result1 == 1"></vxe-table-column>
                                    <vxe-table-column field="result2" :title="result2text" width="70px" v-if="result2 == 1"></vxe-table-column>
                                    <vxe-table-column field="result3" :title="result3text" width="70px" v-if="result3 == 1"></vxe-table-column>
                                    <vxe-table-column field="result_txt" sortable title="大文本结果" width="130" show-overflow></vxe-table-column>
                                    <vxe-table-column field="instrid" sortable title="检验仪器" width="100" show-overflow></vxe-table-column>
                                    <vxe-table-column field="interno" sortable title="通道号" width="100" show-overflow></vxe-table-column>
                                    <vxe-table-column field="alertflag" align="center" sortable title="危急标志" width="60" show-overflow></vxe-table-column>
                                    <vxe-table-column field="result_flag" align="center" sortable title="结果标志" width="60" show-overflow></vxe-table-column>
                                    <vxe-table-column field="redo_flag" align="center" sortable title="复查标志" width="60" show-overflow></vxe-table-column>
                                    <vxe-table-column field="redo_result" sortable title="复查前结果" width="120" show-overflow></vxe-table-column>
                                    <vxe-table-column field="orig_result_num" sortable title="原始数值结果" width="120" show-overflow></vxe-table-column>
                                    <vxe-table-column field="orig_result_str" sortable title="原始文本结果" width="120" show-overflow></vxe-table-column>
                                    <vxe-table-column field="modify_flag" align="center" sortable title="修改标志" width="60" show-overflow></vxe-table-column>
                                    <vxe-table-column field="first_dt" align="center" ortable title="第一次填入时间" width="120" show-overflow></vxe-table-column>
                                    <vxe-table-column field="last_dt" align="center" sortable title="最后修改时间" width="120" show-overflow></vxe-table-column>
                                    <vxe-table-column field="last_user" align="center" sortable title="最后修改人" width="80" show-overflow></vxe-table-column>
                                    <vxe-table-column field="rptunitid" sortable title="报告单元" width="150" show-overflow></vxe-table-column>
                                    <vxe-table-column field="germflag" align="center" sortable title="细菌标志" width="60" show-overflow></vxe-table-column>
                                    <vxe-table-column field="orig_result_flag" align="center" sortable title="原始结果标志" width="160" show-overflow></vxe-table-column>
                                </vxe-table>
                                <div class="fixtotal">
                                    <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span style="color:red;margin-left:10px;float:right;">合计: {{result_amount}}</span>
                                            <div style="clear:both"></div>
                                        </div>
                                    </div>
                            </div>
                        </template>
                    </rm-layout-right>
                </el-tab-pane>
                <el-tab-pane label="申请单" name="tab_master">
                    <vxe-table :data.sync="master_data" :loading="master_Loading" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}" border height="auto" header-align="center" highlight-current-row highlight-hover-column highlight-hover-row how-header-overflow ref="mastertable" resizable show-overflow size="mini" stripe show-header-overflow :optimization="{animat: false}">
                        <vxe-table-column field="report_dt" title="报告时间" align="center" width="120px"></vxe-table-column>
                        <vxe-table-column field="req_groupna" sortable title="分单类别" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="barcode" sortable title="条形码" align="center" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="emer_flag" align="center" sortable title="急" :formatter="['formatSelect', emer_flagOptions]" width="25" show-overflow>
                            <template v-slot="{ row}">
                                <div v-if="row.emer_flag == '1'">
                                    <font color="red" style="font-weight:600;font-size:14px;">急</font>
                                </div>
                                <div v-else>
                                </div>
                            </template>
                        </vxe-table-column>
                        <vxe-table-column field="sample_items" sortable title="申请项目(描述)" width="350" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_statname" align="center" sortable title="状态" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="create_dt" align="center" sortable title="创建时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="recieve_dt" title="接收时间" width="120px" align="center"></vxe-table-column>
                        <vxe-table-column field="recieve_username" title="接收人" width="70px" align="center"></vxe-table-column>
                        <vxe-table-column field="test_dt" title="上机时间" align="center" width="120px"></vxe-table-column>
                        <vxe-table-column field="test_username" title="上机人" width="70px" align="center"></vxe-table-column>
                        <vxe-table-column field="req_deptname" sortable title="申请科室" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_doc" sortable title="申请医生" width="80" align="center" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_bedno" align="center" sortable title="床号" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="specimen_name" align="center" sortable title="标本类型" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_sexname" align="center" sortable title="性别" width="50" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_agestr" align="center" sortable title="年龄" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="base_amount" align="right" sortable title="应收金额" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="create_username" align="center" sortable title="创建人" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="print_dt" align="center" sortable title="打印/执行时间" width="130" show-overflow></vxe-table-column>
                        <vxe-table-column field="print_username" align="center" sortable title="打印/执行人" width="110" show-overflow></vxe-table-column>
                        <vxe-table-column field="print_count" align="center" sortable title="打印次数" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="sampled_dt" align="center" sortable title="采样时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="sampled_username" align="center" sortable title="采样人" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_dt" align="center" sortable title="申请时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="release_dt" align="center" sortable title="发布时间" width="140" show-overflow></vxe-table-column>
                        <vxe-table-column field="prereport_dt" align="center" sortable title="预出报告时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="prereport_comm" sortable title="报告领取说明" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_diag" sortable title="临床诊断" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_id" sortable title="病人ID" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="inp_date" align="center" sortable title="入院日期" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="send_dt" align="center" sortable title="送出时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="send_username" sortable title="送出人" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="charge_dt" align="center" sortable title="计价时间" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="charge_username" sortable title="计价人" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="amount" align="right" sortable title="实收金额" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="sampled_chkusername" title="采样核对者" align="center" width="100px"></vxe-table-column>
                        <vxe-table-column field="reqsource" sortable title="申请单来源" :formatter="['formatSelect', reqsourceOptions]" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_no" sortable title="病历号" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="recieve1_dt" title="工作组接收时间" width="100px"></vxe-table-column>
                        <vxe-table-column field="recieve1_username" title="工作组接收用户" width="100px"></vxe-table-column>
                        <vxe-table-column field="pat_typename" title="病人类型" width="100px"></vxe-table-column>
                        <vxe-table-column field="cancel_dt" title="作废时间" width="120px"></vxe-table-column>
                        <vxe-table-column field="cancel_username" title="作废用户" width="100px"></vxe-table-column>
                        <vxe-table-column field="chargeex_flag" sortable title="计价标志" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="alter_flag" sortable title="报警" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="saleman" sortable title="销售人" align="center" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_cardno" sortable title="就诊卡号" width="120" show-overflow></vxe-table-column>
                        <vxe-table-column field="report_username" title="检验医生姓名" align="center" width="80px"></vxe-table-column>
                        <vxe-table-column field="rechk_username" title="核对医生姓名" align="center" width="80px"></vxe-table-column>
                        <vxe-table-column field="req_comm" sortable title="医生备注" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="reject_dt" title="退回时间" align="center" width="120px"></vxe-table-column>
                        <vxe-table-column field="reject_username" title="退回用户" align="center" width="80px"></vxe-table-column>
                        <vxe-table-column field="reject_reason" title="退回原因" width="150px"></vxe-table-column>
                        <vxe-table-column field="reject_count" title="退回次数" align="center" width="60px"></vxe-table-column>
                        <vxe-table-column field="pat_birth" sortable title="生日" align="center" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_agestr" sortable title="年龄岁数" align="center" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="inp_id" sortable title="住院标志" align="center" width="80" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_diag_icd" sortable title="诊断标准代码" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_address" sortable title="地址" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_nation" sortable title="国籍" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_idcardno" sortable title="身份证号" align="center" width="130" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_phone" sortable title="联系电话" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="charge_typeno" sortable title="费别代码" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="perform_dept" sortable title="执行科室" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_ward" sortable title="病区代码" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="original_reqno" sortable title="原始单号" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="secrecy" sortable title="加密" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="other_stat" sortable title="其它状态" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="specimen_code" sortable title="标本类型代码" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="sample_detail" sortable title="标准备注说明" width="150" show-overflow></vxe-table-column>
                        <vxe-table-column field="req_reason" sortable title="送检目的" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="pat_height" sortable title="身高(CM)" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="weight" sortable title="体重(KG)" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="abo_bldtype" sortable title="ABO血型" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="rh_bldtype" sortable title="RH血型" width="100" show-overflow></vxe-table-column>
                        <vxe-table-column field="discard_username" sortable title="遗弃人" align="center" width="70" show-overflow></vxe-table-column>
                        <vxe-table-column field="discard_dt" sortable title="遗弃时间" align="center" width="120" show-overflow></vxe-table-column>
                    </vxe-table>
                    <div class="fixtotal">
                        <div style="font-size:12px;padding-top:3px;background-color:#fff;"><span style="color:red;margin-left:10px;float:right;">合计: {{mstr_amount}}</span>
                                <div style="clear:both"></div>
                            </div>
                            <!-- <span style="color:blue;margin-left:60px">{{tempRowIndex+1}}/{{TotalPatNum}}</span> -->
                        </div>
                </el-tab-pane>
            </el-tabs>
            <!-- </div> -->
        </div>
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="参考值校验" destroy-on-close :visible.sync="dialogCheckRefVisible" width="900px">
            <template>
                <div style="height:500px;width:100%;position:relative;">
                    <div class="poppagetop">
                        <div style="float:left;width:50%;text-align:left;color:blue;">
                            校验数: {{check_num}}/{{check_amount}}
                        </div>
                        <div style="float:left;width:50%;text-align:right;">

                            <el-button icon="el-icon-switch-button" @click="checkflag=0">停止</el-button>
                            <el-button icon="el-icon-upload2" @click="recordexport" v-has="'PEXPORT'">导出</el-button>
                            <el-button icon="el-icon-close" @click="dialogCheckRefVisible=false">关 闭 </el-button>
                        </div>
                    </div>
                    <div class="poppagecenter">
                        <vxe-table show-overflow ref="refxTable" height="auto" :data.sync="checkRefData" show-header-overflow highlight-current-row highlight-hover-row resizable border size="mini" :span-method="rowspanMethod" header-align:center>
                            <vxe-table-column type="index" title="NO." width="40"></vxe-table-column>
                            <vxe-table-column field="labgroupname" title="工作组" width="100" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="rptunitname" title="报告单元" width="130" header-align="center" class="rowspantop"></vxe-table-column>
                            <vxe-table-column field="rpt_itemname" title="报告项目" width="160" header-align="center" float:top>
                            </vxe-table-column>
                            <vxe-table-column field="diffstr" title="参考值差异" width="250" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="specimen_name" title="标本类型" width="100" header-align="center">
                            </vxe-table-column>
                            <!-- <vxe-table-column field="pat_name" title="姓名" width="60" header-align="center">
                            </vxe-table-column> -->
                            <vxe-table-column field="pat_sex" title="性别" width="40" header-align="center" align="center">
                            </vxe-table-column>
                            <vxe-table-column field="pat_agestr" title="年龄" width="50" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="req_deptname" title="科室" width="120" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="pat_diag_icd" title="诊断" width="100" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="physicycle" title="生理周期" width="100" header-align="center">
                            </vxe-table-column>

                            <vxe-table-column field="sampledate" title="标本日期" width="100" header-align="center" align="center">
                            </vxe-table-column>
                            <vxe-table-column field="sampleno" title="标本号" width="100" header-align="center">
                            </vxe-table-column>
                            <vxe-table-column field="pat_ageyear" title="年龄数值" width="80" header-align="center">
                            </vxe-table-column>
                        </vxe-table>
                    </div>
                </div>
            </template>
        </el-dialog>
        <el-dialog v-el-drag-dialog :close-on-click-modal="false" title="校验完成" destroy-on-close :visible.sync="dialogErrCheckVisible" width="400px" height="50%">
            <template>
                <div v-for="msg in msglist" :key="msg.title" style="over-flow:auto">
                    <h3 style="color:red">{{msg}}</h3>
                </div>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogErrCheckVisible=false" :autofocus="true">确 定</el-button>
                </div>
            </template>
        </el-dialog>
        <!--多选弹窗--->
        <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="dlgTitle" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
            <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
        </el-dialog>
        <el-dialog width="600px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="dlgTitle" :visible.sync="bExportSettingsVisible" :destroy-on-close="true">
            <div style="width:100%;height:380px">
                <table style="font-size:12px;white-space: nowrap;" border="0">
                    <tr>
                        <td align="right"><b>文件名称</b></td>
                        <td>
                            <el-input v-model="exportFileTitle" placeholder="" style="width:500px"></el-input>
                        </td>
                    </tr>
                    <tr style="height:10px">
                    </tr>
                    <tr>
                        <td align="right" style="width:20%"><b>命名说明</b></td>
                    </tr>
                </table>
                <table style="width:100%;ont-size:10px;text-align:left">
                    <col style="width:40px;" />
                    <col style="width:150px;" />
                    <col style="width:150px;" />
                    <col style="width:150px;" />
                    <col style="width:40px;" />
                    <tr>
                        <td></td>
                        <td style="text-align:left">@reportid = 报告ID</td>
                        <td style="text-align:left">@sampledate = 报告日期</td>
                        <td style="text-align:left">@sampleno = 标本号</td>
                        <td></td>
                    </tr>
                    <tr style="text-align:left">
                        <td></td>
                        <td style="text-align:left">@barcode = 条码号</td>
                        <td style="text-align:left">@rptunitid = 报告单元</td>
                        <td style="text-align:left">@pat_name = 病人姓名</td>
                        <td></td>
                    </tr>
                    <tr style="text-align:left">
                        <td></td>
                        <td style="text-align:left">@pat_idcardno = 身份证</td>
                        <td style="text-align:left">@pat_no = 病历号</td>
                        <td style="text-align:left">@req_reason = 送检目的</td>
                        <td></td>
                    </tr>
                </table>
                <table style="font-size:12px;white-space: nowrap;" border="0">
                    <tr style="height:10px">
                    </tr>
                    <tr>
                        <td align="right"><b>命名示例</b></td>
                        <td>
                            <el-input v-model="exampleTitle" placeholder="" style="width:500px" :disabled="true"></el-input>
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td style="text-align:left"><b>&nbsp;&nbsp;&nbsp;2020-08-08_006_血球XT-4000I_12345_张三.pdf</b></td>
                    </tr>
                    <tr style="height:10px">
                    </tr>
                </table>
                <div style="overflow-x: auto; overflow-y: auto; width: 100%; float: left; height: 130px; border: 1px solid #ccc">
                    <template>
                        <div style="over-flow: scroll">
                            <h3 v-for="msg in logList" :key="msg" style="color: black; font-size: 11px">{{ msg }}</h3>
                        </div>
                    </template>
                </div>
                <span style="height:30px;width::100%; text-align: right;box-sizing: border-box;float: right">
                    <el-button @click="BtnRptExport">导出 </el-button>
                    <!-- <el-button @click="BtnCurrentExport">导出选中 </el-button>
                    <el-button @click="BtnBatchExport">导出全部</el-button> -->
                    <el-button @click="bExportSettingsVisible = false">取 消 </el-button>
                </span>
            </div>
        </el-dialog>
        <!--  添加打印检查提醒 -->
        <el-dialog width="600px" height="205px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="dlgTitle" :visible.sync="dialogPrintchk" :destroy-on-close="true">
            <div style="width:100%;height:155px">
                <div style="overflow-x: auto; overflow-y: auto; width: 100%; float: left; height: 130px; border: 1px solid #ccc">
                    <template>
                        <div style="over-flow: scroll">
                            <h3 v-for="msg in forbidList" :key="msg" style="color: black; font-size: 11px">{{ msg }}</h3>
                        </div>
                    </template>
                </div>
                <span style="height:25px;width::100%; text-align: right;box-sizing: border-box;float: right">
                    <el-button @click="dialogPrintchk=false">确定 </el-button>
                </span>
            </div>
        </el-dialog>
        <!--  批量打印提示-->
        <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" v-el-drag-dialog :close-on-click-modal="false">
            <div style="font-size:18px;font-weight:800;">{{ printmsg }}</div>
        </el-dialog>

        <!--导出-->
        <el-dialog title="提示" :visible.sync="dialogExport" width="580px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false">
            <div>
                选择结果则导出左边结果信息，选择明细则导出右边结果明细信息，选择取消则取消本次导出！
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="exportOperate(1)">左表结果</el-button>
                <el-button type="primary" @click="exportOperate(2)">项目明细</el-button>
                <el-button type="primary" @click="exportOperate(3)" v-if="is_ym">药敏明细</el-button>
                <el-button @click="dialogExport = false">取 消</el-button>
            </span>
        </el-dialog>
    </div>
</template>


<script>
import { Promise } from "q";
import { invalid } from "moment";
import XE from "xe-utils"; //引入工具类
XE.mixin({
    // 自定义全局的格式化处理函数
    formatSelect(cellValue, list) {
        let item = list.find((item) => item.value == cellValue);
        return item ? item.label : "";
    },
});
export default {
    name: "LIS481",
    data() {
        const _that = this;
        return {
            pagetopstyle: {
                height: "150px",
            },
            pagecenter: {
                position: "absolute",
                top: "154px",
                bottom: "0px",
                overflow: "auto",
                width: "100%",
                left: "0px",
            },
            currholder: "病人号,卡号,姓名,条码号,报告ID,身份证",
            icon_showselother: "el-icon-caret-bottom",
            Qna: "快捷查询",
            OtherShow: false,
            show_sel: true,
            report_Loading: false,
            report_data: [],
            tab_showflag: "tab_report",
            fieldname: "",
            dlgTitle: "",
            quicklyQ: "",
            sel_rptunit: "",
            sel_rptunitlist: "",
            sel_patno: "",
            sel_patcardno: "",
            sel_reqbedno: "",
            sel_reportcomm: "",
            sel_reqreason: "",
            sel_result4: "",
            forbidList: [],
            // sample_startdt: XE.toDateString(XE.getWhatDay(new Date(), -5), "yyyy-MM-dd"),
            // sample_enddt: XE.toDateString(new Date(), "yyyy-MM-dd"),
            sample_startdt: this.$pub.InitDateTime2(0).datefrom,
            sample_enddt: this.$pub.InitDateTime2(0).dateto,
            // sel_date: ["2009-08-08", "2020-01-01"],
            sel_patname: "",
            sel_patname_mh: true,
            sel_qna_mh: "0",
            sel_pattypecode: "",
            sel_specimencode: "",
            sel_sampleno: "",
            sel_emerflag: "all",
            sel_reqdeptno: "",
            sel_chargetypeno: "",
            sel_chkflag: "all",
            sel_mixrpt: "0",
            sel_rflag: "all",
            sel_rptitemcode: "",
            sel_reqtype: "",
            sel_barcode: "",
            sel_reqdocno: "",
            sel_specimencomm: "all",
            sel_sampleduser: "",
            sel_patdiag: "",
            sel_reportuser: "",
            sel_reqwardno: "",
            sel_itemcombid: "",
            sel_allprint: false,
            sel_isprint: "all",
            sel_ischeck: "all",
            sel_pat_idcardno: "",
            sel_rechkuser: "",
            sel_combno: "",
            sel_outsex: false,
            sel_onlymed: false,
            sel_onlylast: false,
            sel_markno: false,
            sel_txtinfo2: "",
            sel_hospitalcode: "",
            sel_pat_hospcode: "",
            macaddress: "",
            sel_onlyouthospital: false,
            show_right: true,
            is_ym: false, //是否显示药敏
            result_data: [],
            result_Loading: false,
            resusltmed_date: [],
            master_data: [],
            checkRefData: [],
            master_Loading: false,
            dialogMultipleVisible: false,
            dialogCheckRefVisible: false, //校验参考值
            dialogErrCheckVisible: false, //
            dialogPrintchk: false,
            reportheight: "auto",
            resultheight: "auto",
            ymresultheight: "auto",
            startkey: 0,
            endkey: 0,
            rpt_amount: 0,
            check_amount: 0,
            check_num: 0,
            mstr_amount: 0,
            result_amount: 0,
            ymresult_amont: 0,
            ymresultitem_amount: 0,
            printReportid: "",
            reportid: "",
            rechkflag: "",
            unprint_flag: "",
            option1: [],
            option2: [],
            pattypeOption: [],
            rescodeOption: [],
            newArray: [],
            checkObj: {},
            msglist: [],
            result1text: "",
            result2text: "",
            result3text: "",
            result1: "",
            result2: "",
            result3: "",
            emer_flagOptions: [
                { label: "", value: "0" },
                { label: "急", value: "1" },
            ],
            reqsourceOptions: [
                { label: "读取外部系统申请单", value: "0" },
                { label: "LIS门诊采血生成", value: "1" },
                { label: "病区护士站生成", value: "3" },
                { label: "住院医生站生成", value: "4" },
                { label: "标本拆分之后的标本", value: "5" },
                { label: "为院感系统生产", value: "6" },
                { label: "输入病历号开窗选取项目后生成", value: "21" },
                { label: "Lis系统登记生成", value: "22" },
                { label: "通过检验中心登记", value: "23" },
                { label: "外院标本", value: "24" },
                { label: "POCT生成的申请单", value: "25" },
                { label: "报告处理界面录入的申请", value: "26" },
                { label: "住院医生站输血申请", value: "41" },
                { label: "输血申请附带的检验申请", value: "42" },
            ],
            pickerOptions: {
                // 添加跳转今天
                shortcuts: [
                    {
                        text: "今天",
                        onClick(picker) {
                            picker.$emit("pick", new Date());
                            _that.sample_startdt = new Date();
                            _that.sample_enddt = new Date();
                        },
                    },
                ],
            },
            checkflag: 1,
            // 导出修改
            bExportSettingsVisible: false, //导出设置弹窗
            exportFileTitle: "@sampledate_@sampleno_@rptunitid_@pat_no_@pat_name",
            exampleTitle: "@sampledate_@sampleno_@rptunitid_@pat_no_@pat_name",
            logList: [],
            exportIndex: 0,
            dialogVisible: false,
            printmsg: "",
            selectall: false, //全选  用于打印/导出的全选
            howdays: 1, //查询几天内的报告 
            dialogExport: false,
        };
    },
    created() {
        this.initOption();
        this.initDate();
        this.BtnClear();
    },
    watch: {},
    mounted() {
        //定义快捷键F8
        var _this = this;
        document.onkeydown = function (e) {
            let key = window.event.keyCode;
            switch (key) {
                case 119: //查询F8
                    _this.BtnQuery();
                    break;
            }
        };
        //页面加载完就要焦点聚焦了
        // this.$refs.refQuicklyQ.focus();
    },
    updated() {},
    methods: {
        ChangeQ() {
            //收缩和展开也添加焦点聚焦快捷查询，变更名称
            this.$refs.refQuicklyQ.focus();
            if (this.sel_qna_mh == "1") {
                this.Qna = "姓名查询";
                this.currholder = "姓名 (去除勾选姓名模糊，可恢复快捷查询)";
            } else {
                this.Qna = "快捷查询";
                this.currholder = "病人号,卡号,姓名,条码号,报告ID,身份证";
            }
        },
        popMultipleChk(e, fieldname, option, title) {
            let temp = XE.clone(option, true);
            this.option1 = [];
            this.option2 = [];
            if (e != "") {
                let k = e.split(",");
                k.forEach((item) => {
                    let ndata = temp.find((m) => m.data == item);
                    if (ndata != undefined && ndata != null) {
                        this.option2.push(ndata);
                    }
                });
                temp.forEach((item) => {
                    if (k.indexOf(item.data + "") < 0) {
                        this.option1.push(item);
                    }
                });
            } else {
                this.option1 = temp;
            }
            this.fieldname = fieldname;
            this.dlgTitle = title;
            this.dialogMultipleVisible = true;
        },
        closedialog(value, name) {
            if (value != "close") {
                this[name] = value;
            }
            this.dialogMultipleVisible = false;
        },
        async initOption() {
            if (typeof jsObj != "undefined") {
                var computeInfo = jsObj.GetComputeInfo();
                var arr = computeInfo.split("\r");
                if (arr.length == 3) {
                    this.macaddress = arr[0];
                }
            } else {
                this.macaddress = "Default";
            }
            try {
                //针对权限问题修复组件查询url
                const res = await this.$tool.request({
                    url: "LIS/LIS4/LIS481",
                    method: "post",
                    data: {
                        action: "initoption",
                    },
                });

                this.pattypeOption = res.pattypeOption;
                this.rescodeOption = res.rescodeOption;
            } catch (e) {
                this.$message.warning(e);
            }
        },
        //取设置默认时间
        async initDate() {
            try {
                const res = await this.$tool.request({
                    url: "LIS/LIS4/LIS481",
                    method: "post",
                    data: {
                        action: "initDate",
                    },
                });
                if (res) {
                    this.howdays = XE.toInteger(res);
                    if (this.howdays >= 1) {
                        this.sample_startdt = this.$pub.InitDateTime2(this.howdays - 1).datefrom;
                    }
                }
            } catch (e) {
                this.$message.warning(e);
            }
        },
        BtnOtherShow() {
            this.OtherShow = !this.OtherShow;
            this.$refs.refQuicklyQ.focus(); // 收缩和展开也添加焦点聚焦快捷查询
        },
        BtnQuery() {
            this.report_Loading = true;
            this.selectall = false; //用于重置全选
            this.printReportid = "";
            this.rechkflag = "";
            this.unprint_flag = "";
            this.exportna = "";
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS481",
                    method: "post",
                    data: {
                        action: "unrechk_lab_report_query",
                        quicklyQ: this.quicklyQ,
                        sample_startdt: this.sample_startdt,
                        sample_enddt: this.sample_enddt,
                        sel_rptunit: this.sel_rptunit,
                        sel_rptunitlist: this.sel_rptunitlist,
                        sel_patno: this.sel_patno,
                        sel_patcardno: this.sel_patcardno,
                        sel_reqbedno: this.sel_reqbedno,
                        sel_reportcomm: this.sel_reportcomm,
                        sel_reqreason: this.sel_reqreason,
                        sel_result4: this.sel_result4,
                        sel_patname: this.sel_patname,
                        sel_patname_mh: this.sel_patname_mh ? "1" : "0",
                        sel_qna_mh: this.sel_qna_mh,
                        sel_pattypecode: this.sel_pattypecode,
                        sel_specimencode: this.sel_specimencode,
                        sel_sampleno: this.sel_sampleno,
                        sel_emerflag: this.sel_emerflag,
                        sel_reqdeptno: this.sel_reqdeptno,
                        sel_chargetypeno: this.sel_chargetypeno,
                        sel_chkflag: this.sel_chkflag,
                        sel_mixrpt: this.sel_mixrpt,
                        sel_rflag: this.sel_rflag,
                        sel_rptitemcode: this.sel_rptitemcode,
                        sel_barcode: this.sel_barcode,
                        sel_reqtype: this.sel_reqtype,
                        sel_reqdocno: this.sel_reqdocno,
                        sel_specimencomm: this.sel_specimencomm,
                        sel_sampleduser: this.sel_sampleduser,
                        sel_patdiag: this.sel_patdiag,
                        sel_reportuser: this.sel_reportuser,
                        sel_reqwardno: this.sel_reqwardno,
                        sel_itemcombid: this.sel_itemcombid,
                        sel_allprint: this.sel_allprint ? "1" : "0",
                        sel_isprint: this.sel_isprint,
                        sel_ischeck: this.sel_ischeck,
                        sel_pat_idcardno: this.sel_pat_idcardno,
                        sel_rechkuser: this.sel_rechkuser,
                        sel_combno: this.sel_combno,
                        sel_outsex: this.sel_outsex ? "1" : "0",
                        sel_onlymed: this.sel_onlymed ? "1" : "0",
                        sel_onlylast: this.sel_onlylast ? "1" : "0",
                        sel_markno: this.sel_markno ? "1" : "0",
                        sel_txtinfo2: this.sel_txtinfo2,
                        sel_hospitalcode: this.sel_hospitalcode,
                        sel_pat_hospcode: this.sel_pat_hospcode,
                    },
                })
                .then((res) => {
                    this.report_data = res.Data;
                    this.result_data = [];
                    this.report_Loading = false;
                    if (res.total > 5000) {
                        this.$message({
                            type: "info",
                            message: "超过5000行只显示前5000行数据！",
                        });
                    }
                    this.$refs.refQuicklyQ.focus();
                    if (this.report_data.length > 0) {
                        this.$refs.reportTable.setCurrentRow(this.report_data[0]);
                        this.queryResult(this.report_data[0]);
                        this.printReportid = this.report_data[0].reportid;
                        this.rechkflag = this.report_data[0].rechkflag;
                        this.unprint_flag = this.report_data[0].unprint_flag;
                        this.exportna = this.report_data[0].reportid + "-" + this.report_data[0].pat_name;
                    }
                    this.rpt_amount = res.total;
                    this.OtherShow = true;
                    this.BtnOtherShow();
                })
                .catch((e) => {
                    this.$message.error(e);
                });
        },
        reportchange_Event({ row, rowIndex, column, columnIndex }, event) {
            this.printReportid = row.reportid;
            this.rechkflag = row.rechkflag;
            this.unprint_flag = row.unprint_flag;
            this.exportna = row.reportid + "-" + row.pat_name;
            this.queryResult(row);
        },
        queryResult(row) {
            this.result_Loading = true;
            this.$tool
                .request({
                    url: "LIS/LIS4/LIS481",
                    method: "post",
                    data: {
                        action: "get_labresult",
                        reportid: row.reportid,
                        rptunitid: row.rptunitid,
                        macaddress: this.macaddress,
                    },
                })
                .then((res) => {
                    if (res.rtn.length > 1) {
                        //药敏
                        this.is_ym = true;
                        this.result_data = res.rtn[0];
                        this.resusltmed_date = res.rtn[1];
                        this.result_amount = this.result_data.length;
                        this.ymresultitem_amount = this.resusltmed_date.length;
                    } else {
                        this.is_ym = false;
                        this.result_data = res.rtn[0];
                        this.result1text = res.result1text;
                        this.result2text = res.result2text;
                        this.result3text = res.result3text;
                        this.result1 = res.result1;
                        this.result2 = res.result2;
                        this.result3 = res.result3;
                        this.result_amount = this.result_data.length;
                    }
                    this.result_Loading = false;
                })
                .catch((e) => {
                    this.$message.error(e);
                });
        },
        tabclick_Event(tab, event) {
            if (tab.label == "报告单") {
                this.show_right = true;
                // this.middle_center.right = "575px"
            }
            if (tab.label == "申请单") {
                this.show_right = false;
                // this.middle_center.right = "0px"
                let row = this.$refs.reportTable.getCurrentRow();
                if (XE.isNull(row)) {
                    this.$message.error("请您先选择一条报告单数据！");
                    return false;
                } else {
                    this.master_Loading = true;
                    //获取申请单数据
                    this.$tool
                        .request({
                            url: "LIS/LIS4/LIS481",
                            method: "post",
                            data: {
                                action: "get_reqmaster",
                                pat_id: row.pat_id,
                            },
                        })
                        .then((res) => {
                            this.master_Loading = false;
                            if (res == "0") {
                                this.master_data = [];
                                this.$message.error("无数据返回，原因:所选数据病人ID为空。");
                            } else {
                                this.master_data = res.Data;
                                this.mstr_amount = this.master_data.length;
                            }
                        })
                        .catch((e) => {
                            this.$message.error(e);
                        });
                }
            }
        },
        // 添加查阅病历
        QueryPatcase() {
            if (!this.printReportid) return false;
            this.GetPatcase(this.printReportid);
        },
        GetPatcase(reportid) {
            this.$pub.getPatcase(this, reportid, 3);
        },
        /**
         *
         * 合并导出按钮，有勾选则按照勾选，无勾选则导出选中行
         * 
         *  1.添加功能 所有表格所有数据导出
         *                  只导出已审核的报告单
         *                  单次最大导出份数:200
         *
         *  2.参考lis6先做个文件名称可选填的功能
         *              待补充：
         *                   单个XML文件、合并XML文件、XML编码、更新打印日志
         *
         *  3. 文件名称说明:
         *                                          @reportid           = 报告ID
         *                                          @sampledate    = 报告日期
         *                                          @sampleno        = 标本号
         *                                          @barcode           = 条码号
         *                                          @rptunitid          = 报告单元
         *                                          @pat_name       = 病人姓名
         *                                          @pat_no                = 病历号
         *                                          @pat_idcardno = 身份证号护照号
         *                                          @req_reason     = 送检目的
         *          忽略大小写
         */
        exportOperate(index) {
            let tableColumn = [];
            let extableColumn = [];
            if (index == "1") {
                //导出结果
                tableColumn = this.$refs.reportTable.getColumns();
                tableColumn.forEach((item) => {
                    extableColumn.push({ title: item.title, field: item.property });
                });
                this.$pub.exportTableExcel(this.report_data, extableColumn, "LIS481 解除审核报告查询(报告单)result.xlsx");
            } else if (index == "2") {
                //导出明细
                tableColumn = this.$refs.ymresulttable.getColumns();
                tableColumn.forEach((item) => {
                    extableColumn.push({ title: item.title, field: item.property });
                });
                this.$pub.exportTableExcel(this.result_data, extableColumn, "LIS481 解除审核报告查询(报告单)detail.xlsx");
            } else {
                if (this.is_ym) {
                    let tableColumn = this.$refs.ymresulttable2.getColumns();
                    tableColumn.forEach((item) => {
                        extableColumn.push({ title: item.title, field: item.property });
                    });
                    this.$pub.exportTableExcel(this.resusltmed_date, extableColumn, "LIS481 解除审核报告查询(报告单)detail2.xlsx");
                }
            }
            this.dialogExport = false;
        },
        BtnExcelExport() {
            if (this.tab_showflag == "tab_report") {
                this.dialogExport = true;
            } else {
                let extableColumn = [];
                let tableColumn = this.$refs.mastertable.getColumns();
                tableColumn.forEach((item) => {
                    extableColumn.push({ title: item.title, field: item.property });
                });
                this.$pub.exportTableExcel(this.master_data, extableColumn, "LIS481 解除审核报告查询(申请单)result.xlsx");
            }
        },
        BtnExport() {
            this.dlgTitle = "导出文件设置";
            this.logList = [];
            this.bExportSettingsVisible = true; //导出设置弹框
        },
        //导出选中
        BtnRptExport() {
            let exportData = this.report_data.filter((item) => {
                return item.cp_selection == "1";
            });
            if (!(exportData.length > 0)) {
                this.BtnCurrentExport();
            } else {
                this.BtnBatchExport();
            }
        },

        BtnCurrentExport() {
            this.logList = [];
            var COPIES = 0;
            if (this.$refs.reportTable.afterFullData.length <= COPIES) {
                this.logList.push("请先查询出有效数据。");
                return false;
            }
            if (this.printReportid == "") {
                this.logList.push("导出失败：请您先选择一条需导出的报告。");
                return false;
            }
            if (this.rechkflag != "9") {
                this.logList.push("导出失败：当前报告未审核。");
                return false;
            }
            if (this.unprint_flag == "8") {
                this.logList.push("导出失败:当前报告单需要单独授权。");
                return false;
            }
            let currentrow = this.$refs.reportTable.getCurrentRow();
            var reportna = this.transExportName(currentrow) + ".pdf";
            this.$pub.PDFExport(this, this.printReportid, reportna, "LIS481", "1");
            this.logList.push("导出成功。");
        },
        //导出全部
        BtnBatchExport() {
            this.logList = [];
            let MAXLEN = 200;
            let data = this.report_data.filter((item) => {
                return item.cp_selection == "1";
            });
            let rechkdata = [];
            let exportdata = [];
            if (!data.length > 0) {
                this.logList.push("请先查询出有效数据。");
                return false;
            }
            data.forEach((e) => {
                if (e.rechkflag == "9" && e.unprint_flag != "8") rechkdata.push(e);
            });
            this.logList.push("当前勾选报告数: " + data.length + " 张 ，  已审核数:" + rechkdata.length + " 张");
            this.logList.push("");
            if (!rechkdata.length > 0) {
                this.logList.push("当前无可导出的报告。");
                return false;
            } else {
                if (rechkdata.length > 200) {
                    this.logList.push("审核报告数大于最大导出张数:" + MAXLEN + ",导出前" + MAXLEN + "张报告。");
                    this.logList.push("");
                }
                MAXLEN = rechkdata.length > MAXLEN ? MAXLEN : rechkdata.length;
                for (let i = 0; i < MAXLEN; i++) {
                    exportdata[i] = {
                        reportid: rechkdata[i].reportid,
                        pdfna: this.transExportName(rechkdata[i]) + ".pdf",
                    };
                }
                this.PDFBatchExport(this, exportdata, "LIS481_batch", "1", 0, "");
            }
        },
        //获取文件名
        transExportName(detail) {
            let newna = this.exportFileTitle
                .replace(/@reportid/g, detail.reportid == null ? "" : detail.rptunitname)
                .replace(/@sampledate/g, detail.sampledate == null ? "" : detail.sampledate)
                .replace(/@sampleno/g, detail.sampleno == null ? "" : detail.sampleno)
                .replace(/@barcode/g, detail.barcode == null ? "" : detail.barcode)
                .replace(/@rptunitid/g, detail.rptunitid == null ? "" : detail.rptunitname + "(" + detail.rptunitid + ")")
                .replace(/@pat_name/g, detail.pat_name == null ? "" : detail.pat_name)
                .replace(/@pat_no/g, detail.pat_no == null ? "" : detail.pat_no)
                .replace(/@pat_idcardno/g, detail.pat_idcardno == null ? "" : detail.pat_idcardno)
                .replace(/@req_reason/g, detail.req_reason == null ? "" : detail.req_reason);
            var reg = new RegExp('[/:*?"<>|	]', "g");
            newna = newna.replace(reg, "");
            return newna;
        },
        //递归调用打印 返回日志
        PDFBatchExport(that, data, prgno, env, index, folderna) {
            if (index < data.length) {
                this.exportIndex++;
                let item = data[index];
                // this.$nextTick(()=>{
                this.logList[this.logList.length - 1] = "正在生成 :" + "(" + (index + 1) + "/" + data.length + ")" + item.pdfna;
                // })
                this.$forceUpdate();
                return new Promise((s, f) => {
                    this.$tool
                        .request({
                            url: "ucent/print",
                            method: "post",
                            data: {
                                action: "rptPDFTrans",
                                reportid: item.reportid,
                                pdfna: item.pdfna,
                                folderna: folderna,
                                env: env,
                            },
                        })
                        .then((res) => {
                            if (res.flag == "0") {
                                that.$alert(res.msg);
                            } else if (res.flag == "1") {
                                folderna = res.folderna;
                                this.PDFBatchExport(this, data, "LIS481_batch", "1", index + 1, folderna);
                            }
                            s();
                        })
                        .catch((e) => {
                            that.$alert("报告导出PDF出错:获取报告单失败。", "错误", {
                                confirmButtonText: "确定",
                            });
                            f();
                        });
                });
            } else {
                //全部导出
                this.logList.push("后台数据生成结束!");
                this.rptZip(folderna, "LIS481_batch");
            }
        },
        //压缩文件夹
        rptZip(folderna, prgno) {
            return new Promise((s, f) => {
                this.$tool
                    .request({
                        url: "ucent/print",
                        method: "post",
                        data: {
                            action: "rptZip",
                            folderna: folderna,
                        },
                    })
                    .then((res) => {
                        this.logList.push(res.msg);
                        this.logList.push("正在下载文件。");
                        let p = {
                            prgno: prgno,
                            filename: folderna,
                            zipPath: res.zipPath,
                        };
                        this.batchExport(this, p, folderna + ".zip");
                        s();
                    })
                    .catch((e) => {
                        this.$alert(e, "错误", {
                            confirmButtonText: "确定",
                        });
                        f();
                    });
            });
        },
        //下载ZIP到客户端
        batchExport(that, p, filename) {
            return new Promise((s, f) => {
                this.$tool
                    .request({
                        url: "/ucent/downloadfile",
                        method: "post",
                        responseType: "blob",
                        data: {
                            ...p,
                        },
                    })
                    .then((res) => {
                        if (res.hasOwnProperty("errcode")) {
                            let msg = res.errmsg;
                            if (!msg) {
                                msg = "导出数据失败！";
                            } else {
                                msg = "导出数据失败   " + msg;
                            }
                            that.$alert(msg).then(() => {
                                f();
                                return false;
                            });
                        } else {
                            if (res) {
                                if (res.size > 0) {
                                    let blob = new Blob([res], {
                                        type: "application/octet-stream",
                                    });
                                    let reader = new FileReader();
                                    reader.readAsDataURL(blob);
                                    reader.onload = (e) => {
                                        let objectUrl = window.URL.createObjectURL(blob);
                                        let a = document.createElement("a");
                                        a.download = filename;
                                        a.href = objectUrl;
                                        a.click();
                                        a.remove();
                                        window.URL.revokeObjectURL(objectUrl);
                                        this.logList.push("清除服务器临时文件,下载成功。");
                                    };
                                } else {
                                    that.$alert("导出数据为空！", "提示");
                                }
                            }
                            s();
                        }
                    });
            });
        },
        BtnClear() {
            this.show_sel = true;
            this.report_Loading = false;
            this.report_data = [];
            this.result_data = [];
            this.resusltmed_date = [];
            this.quicklyQ = "";
            this.tab_showflag = "tab_report";
            this.sel_rptunit = "";
            this.sel_rptunitlist = "";
            this.sel_patno = "";
            this.sel_patcardno = "";
            this.sel_reqbedno = "";
            this.sel_reportcomm = "";
            this.sel_reqreason = "";
            this.sel_result4 = "";
            this.sample_startdt = this.$pub.InitDateTime2(this.howdays - 1).datefrom;
            // this.sel_date = [XE.toDateString(XE.getWhatDay(new Date(), -7), "yyyy-MM-dd"), XE.toDateString(new Date(), "yyyy-MM-dd")];
            this.sel_patname = "";
            this.sel_patname_mh = false;
            this.sel_qna_mh = "0";
            this.sel_pattypecode = "";
            this.sel_specimencode = "";
            this.sel_sampleno = "";
            this.sel_emerflag = "all";
            this.sel_reqdeptno = "";
            this.sel_chargetypeno = "";
            this.sel_chkflag = "all";
            this.sel_mixrpt = "0";
            this.sel_rflag = "all";
            this.sel_rptitemcode = "";
            this.sel_barcode = "";
            this.sel_reqtype = "";
            this.sel_reqdocno = "";
            this.sel_specimencomm = "all";
            this.sel_sampleduser = "";
            this.sel_patdiag = "";
            this.sel_reportuser = "";
            this.sel_reqwardno = "";
            this.sel_itemcombid = "";
            this.sel_allprint = false;
            this.sel_isprint = "all";
            this.sel_ischeck = "all";
            (this.sel_pat_idcardno = ""), (this.sel_rechkuser = "");
            this.sel_combno = "";
            this.sel_outsex = false;
            this.sel_onlymed = false;
            this.sel_onlylast = false;
            this.sel_markno = false;
            this.sel_txtinfo2 = "";
            this.sel_hospitalcode = "";
            this.sel_pat_hospcode = "";
            this.sel_onlyouthospital = false;
            this.show_right = true;
            this.printReportid = "";
            this.rechkflag = "";
            this.unprint_flag = "";
            this.exportna = "";
            this.Qna = "快捷查询";
            this.currholder = "病人号,卡号,姓名,条码号,报告ID,身份证";
            // this.$refs.refQuicklyQ.focus();
        },
        //校验参考值
        //修改校验参考值
        BtnCheckRef() {
            //不存在数据时，弹窗提示。
            if (this.report_data == null || this.report_data.length == 0) {
                this.$alert("请先搜索出报告单数据再校验参考值。", "提示", {
                    confirmButtonText: "确定",
                });
                return false;
            } else {
                //存在数据
                this.dialogCheckRefVisible = true;
                this.msglist = []; //获取失败信息列表
                this.checkflag = 1;
                this.check_num = 0;
                if (this.rpt_amount > 5000) {
                    this.check_amount = 5000;
                } else this.check_amount = this.rpt_amount;
                this.CheckRef(0);
            }
        },
        //递归查询参考值
        CheckRef(index) {
            if (index < this.report_data.length && this.checkflag == 1) {
                let item = this.report_data[index];
                this.check_num = index + 1;
                // this.$forceUpdate();
                this.$tool
                    .request({
                        url: "LIS/LIS4/LIS481",
                        method: "post",
                        data: {
                            action: "checkrefs",
                            reportid: item.reportid,
                        },
                    })
                    .then((res) => {
                        if (res.err == 1) {
                            for (let i = 0; i < res.list.length; i++) {
                                //筛选出，报告单元ID、检验项目、标本类型、性别相同的首行数据
                                var flag = true;
                                for (var j = this.checkRefData.length - 1; j >= 0; j--) {
                                    //报告单元,报告项目，样本类型，性别，年龄，科室，诊断，生理周期，参考值差异
                                    if (res.list[i].rptunitname == this.checkRefData[j].rptunitname && res.list[i].rpt_itemname == this.checkRefData[j].rpt_itemname && res.list[i].specimen_name == this.checkRefData[j].specimen_name && res.list[i].pat_sex == this.checkRefData[j].pat_sex && res.list[i].pat_agestr == this.checkRefData[j].pat_agestr && res.list[i].diffstr == this.checkRefData[j].diffstr && res.list[i].req_deptname == this.checkRefData[j].req_deptname && res.list[i].pat_diag_icd == this.checkRefData[j].pat_diag_icd && res.list[i].physicycle == this.checkRefData[j].physicycle) {
                                        flag = false;
                                        break;
                                    }
                                }
                                if (flag) {
                                    this.checkRefData.push(res.list[i]); //添加
                                }
                            }
                        }
                        this.CheckRef(index + 1);
                    })
                    .catch((e) => {
                        this.$message.error(e);
                    });
            } else {
                this.checkflag = 1;
            }
        },
        recordexport() {
            this.$refs.refxTable.exportCsv({ filename: "校验参考值" });
        },
        cellClickEvent({ row, column }) {},
        //"rm-cancel"; //作废
        //"rm-disable"; //禁用
        //"rm-readonly"; //只读
        //"rm-alert"; //警告
        reportRowName({ row, rowIndex }) {
            if (row.rechk_dt != "" && row.rechk_dt != " " && row.rechk_dt != null) {
                if (XE.toNumber(row.print_count) > 0) {
                    return "rm-gray"; //审核过打印的
                } else {
                    return "colrow"; //没打印的
                }
            }
        },
        reportCellName({ row, rowIndex, column, columnIndex }) {
            if (column.property == "alter_flag") {
                if (row.alter_flag == "1" || row.alter_flag == "2") {
                    return "colred";
                }
            } else if (column.property == "redo_flag") {
                if (row.redo_flag == "2" || row.redo_flag == "3") {
                    return "colgreen";
                }
            } else if (column.property == "pat_name" || column.property == "pat_no") {
                // 添加链接查询颜色
                return "col-blue";
            } else if (column.property == "unprint_reason") {
                return "col-red";
            }

            // if (column.property == "emer_flag") {
            //     if (row.emer_flag != "0") {
            //         return "rm_cell_green";
            //     }
            // }
        },
        // 通用行合并函数（将相同多列数据合并为一行）
        rowspanMethod({ row, $rowIndex, column, data }) {
            let fields = ["labgroupname", "rptunitname", "rpt_itemname", "specimen_name"];
            let cellValue = row[column.property];
            if (cellValue && fields.includes(column.property)) {
                let prevRow = data[$rowIndex - 1];
                let nextRow = data[$rowIndex + 1];
                if (prevRow && prevRow[column.property] === cellValue) {
                    return { rowspan: 0, colspan: 0 };
                } else {
                    let countRowspan = 1;
                    while (nextRow && nextRow[column.property] === cellValue) {
                        nextRow = data[++countRowspan + $rowIndex];
                    }
                    if (countRowspan > 1) {
                        return { rowspan: countRowspan, colspan: 1 };
                    }
                }
            }
        },
        //打印
        // 合并打印按钮 有勾选默认打印勾选 无勾选打印选中行报告
        BtnPrint() {
            let printData = this.report_data.filter((item) => {
                return item.cp_selection == "1";
            });
            if (!(printData.length > 0)) {
                this.BtnCurrentPrint();
            } else {
                if (printData.length > 0) {
                    this.BtnBatchPrint();
                }
            }
        },
        // 恢复选中行打印
        BtnCurrentPrint() {
            if (this.printReportid == "") {
                this.$message("请先选择一份报告进行打印!");
                return false;
            } else if (this.rechkflag != "9") {
                this.$message("当前报告未审核，不可打印!");
                return false;
            } else if (this.unprint_flag == "8") {
                this.$message("当前报告需要授权打印!");
                return false;
            } else if (this.printReportid != "" && this.rechkflag == "9" && this.unprint_flag != "8") {
                this.printmsg = "正在打印，共1份报告";
                this.dialogVisible = true;
                this.$pub.printreport(this, this.printReportid, "1", "", "1", "1");
                setTimeout(() => {
                    this.dialogVisible = false;
                }, 2000);
            }
        },
        // 添加勾选打印
        BtnBatchPrint() {
            //打印
            let printData = this.report_data.filter((item) => {
                return item.cp_selection == "1";
            });
            let len = printData.length;
            if (len > 0) {
                let name = [];
                printData.forEach((item) => {
                    //遍历是否有不一样的的姓名的患者打印报告，有则提醒
                    if (name.indexOf(item.pat_name) > -1) {
                        //throw Error();
                    } else {
                        name.push(item.pat_name);
                    }
                });
                if (name.length > 1) {
                    //有至少两个人的报告
                    this.$confirm("当前选中多个病人的报告单，你确定要打印吗？", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    })
                        .then(() => {
                            this.PrintReport(len);
                        })
                        .catch((e) => {});
                } else {
                    //只有一个人的报告
                    this.PrintReport(len);
                }
            }
        },
        // 发送打印指令
        PrintReport(len) {
            this.printmsg = "正在打印，共" + len + "份报告";
            this.dialogVisible = true;
            this.forbidList = [];
            let printData = this.report_data.filter((item) => {
                return item.cp_selection == "1";
            });
            if (printData.length > 0) {
                this.printchk(printData, 0);
            }
        },
        //循环校验是否可打印、打印、返回日志
        printchk(data, index) {
            if (index < data.length) {
                let item = data[index];
                var reportid = data[index].reportid;
                // return new Promise((s, f) => {
                this.$tool
                    .request({
                        url: "LIS/LIS4/LIS481",
                        method: "post",
                        data: {
                            action: "chkrechk",
                            reportid: reportid,
                        },
                    })
                    .then((res) => {
                        if (res) {
                            if (res.ecode == 0) {
                                this.$pub.printreport(this, reportid, "1", "", "1").then(() => {
                                    let k = Number(data[index].print_count);
                                    data[index].print_count = k + 1;
                                });
                            } else if (res.ecode == -1) {
                                this.forbidList.push(res.erromsg);
                                this.dialogVisible = false;
                                this.dialogPrintchk = true;
                            }
                            this.printchk(data, index + 1);
                        }
                        //     s();
                        // })
                        // .catch((e) => {
                        //     this.dialogVisible = false;
                        //     this.$message.warning(e);
                        //     f();
                        // });
                    })
                    .catch((e) => {
                        console.log("e", e);
                        this.dialogVisible = false;
                    });
            } else {
                //全部导出
                this.dialogVisible = false;
                if (this.forbidList.length > 0) {
                    this.forbidList.push("打印结束，本次打印成功" + (data.length - this.forbidList.length) + "份报告,打印失败" + this.forbidList.length + "份报告。");
                }
            }
        },
        //双击链接查询
        cellDblClickEvent({ row, column }) {
            if (column.property == "pat_no") {
                this.sel_patno = row.pat_no;
                this.BtnQuery();
            } else if (column.property == "pat_name") {
                this.sel_patname = row.pat_name;
                this.BtnQuery();
            }
        },
        //全选/取消
        ChkAll(e) {
            if (this.report_data != null && this.report_data.length > 0) {
                this.report_data.forEach((item) => {
                    if (item.rechkflag == 9 && item.unprint_flag != 8) {
                        item.cp_selection = this.selectall == true ? "1" : "0";
                    }
                });
            }
        },
        // 勾选点击提示
        handleCheckedPrintChange(row, rowIndex) {
            //控制单选状态
            if (row.cp_selection != "0") {
                if (row.notserviceprint == "1") {
                    this.$alert("当前报告不可在服务台打印！", "提示", {
                        confirmButtonText: "确定",
                        callback: (action) => {
                            this.$nextTick(() => {
                                row.cp_selection = "0";
                            });
                        },
                    });
                }
                if (row.rechkflag != 9) {
                    //9已审核
                    this.$alert("当前报告未审核，不可打印！", "提示", {
                        confirmButtonText: "确定",
                        callback: (action) => {
                            this.$nextTick(() => {
                                row.cp_selection = "0";
                            });
                        },
                    });
                }
                if (row.unprint_flag == 8) {
                    this.$alert("当前报告需要单独授权才能打印，请到指定地点或用户处打印！", "提示", {
                        confirmButtonText: "确定",
                        callback: (action) => {
                            this.$nextTick(() => {
                                row.cp_selection = "0";
                            });
                        },
                    });
                }
                if (row.prereport == "1") {
                    this.$alert("当前报告为初步报告，只可查询，不可打印！", "提示", {
                        confirmButtonText: "确定",
                        callback: (action) => {
                            this.$nextTick(() => {
                                row.cp_selection = "0";
                            });
                        },
                    });
                }
            }
        },
        //预览
        BtnPreView() {
            if (this.printReportid == "") {
                this.$message("请先选择一份报告进行预览!");
                return false;
            } else if (this.rechkflag != "9") {
                this.$message("当前报告未审核，不允许预览!");
                return false;
            } else if (this.unprint_flag == "8") {
                this.$message("当前报告需要单独授权才能预览");
                return false;
            } else if (this.printReportid != "" && this.rechkflag == "9" && this.unprint_flag != "8") {
                this.$pub.printreport(this, this.printReportid, "2", "", "1", "1");
            }
        },
        //自助打印测试
        BtnAutoPrint() {
            if (this.printReportid == "") {
                this.$message("请先选择一份报告进行自助打印测试!");
                return false;
            } else if (this.rechkflag != "9") {
                this.$message("当前报告未审核，不可自助打印测试!");
                return false;
            } else if (this.unprint_flag == "8") {
                this.$message("当前报告需要单独授权，不可自助打印测试!");
                return false;
            } else if (this.printReportid != "" && this.rechkflag == "9") {
                this.$pub.printreport(this, this.printReportid, "1", "", "2", "1");
            }
        },
        Focus(event) {
            event.currentTarget.select();
        },
    },
};
</script>

<style scoped>
::v-deep .el-checkbox__inner::after {
    border: 2px solid #000000 !important;
    box-sizing: content-box;
    content: "";
    border-left: 0 !important;
    border-top: 0 !important;
    height: 7px;
    left: 4px;
    position: absolute;
    top: 1px;
    transform: rotate(45deg) scaleY(0);
    width: 3px;
    transition: transform 0.15s ease-in 0.05s;
    transform-origin: center;
}
::v-deep .el-checkbox__input.is-disabled + span.el-checkbox__label {
    color: #000000;
    cursor: not-allowed;
}
::v-deep .el-checkbox__label {
    display: inline-block;
    padding-left: 5px;
}
::v-deep .el-checkbox__input.is-disabled .el-checkbox__inner,
.el-checkbox__input.is-disabled.is-checked .el-checkbox__inner + .el-input.is-disabled .el-input__inner {
    background-color: #ffffff !important;
}
::v-deep .el-input--suffix .el-input__inner {
    padding-right: 5px;
}
.middle-tab-bottom {
    position: absolute;
    top: 0px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}
.pagetop {
    left: 0;
    right: 0;
    height: 305px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
    position: absolute;
    z-index: 99;
    overflow-x: auto;
    white-space: nowrap;
}
.pagecenter {
    position: absolute;
    top: 125px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}
.pagebottom {
    position: absolute;
    width: 100%;
    left: 0;
    margin-top: 4px;
    height: 36px;
    bottom: 0px;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    border: solid 1px #ccc;
}

.right-inser {
    position: absolute;
    top: 0;
    bottom: 0px;
    overflow: auto;
    width: 100%;
    right: 0px;
}

table tr td:nth-child(odd) {
    text-align: right;
    white-space: nowrap;
}
table tr td:nth-child(even) {
    text-align: left;
}
table tr td:nth-child(1) {
    width: 80px;
}
table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
}
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}
.avatar-uploader .el-upload:hover {
    border-color: #409eff;
}
.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}
.avatar {
    width: 178px;
    height: 178px;
    display: block;
}

.avatar-uploader-icon1 {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 50px;
    line-height: 50px;
    text-align: center;
}
.avatar1 {
    width: 178px;
    height: 50px;
    display: block;
}
.middle-tab-top {
    position: absolute;
    top: 0px;
    width: 100%;
    height: 200px;
}
.middle-bottom {
    position: absolute;
    top: 37px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}
.middle-tab-bottom {
    position: absolute;
    top: 203px;
    width: 100%;
    bottom: 0px;
    overflow: auto;
}
.poppagetop {
    width: 100%;
    height: 24px;
    -webkit-box-pack: left;
    -webkit-box-align: center;
    position: absolute;
    /* border: 1px solid #ccc; */
    z-index: 999;
}
.poppagecenter {
    position: absolute;
    overflow: auto;
    top: 27px;
    width: 100%;
    height: 450px;
    left: 0;
}
::v-deep .el-select-dropdown__wrap {
    max-width: 400px;
}
::v-deep .vxe-table .vxe-body--row.row--hover td {
    background-color: #d7f1fd;
    vertical-align: top !important;
}
::v-deep .vxe-table.size--mini .vxe-body--column,
.vxe-table.size--mini .vxe-footer--column,
.vxe-table.size--mini .vxe-header--column {
    padding: 1px 0;
    vertical-align: top !important;
}
::v-deep .vxe-table .vxe-sort-wrapper {
    padding: 0 0px;
}
::v-deep .colred {
    background-color: red !important;
}
::v-deep .colgreen {
    background-color: #00ff00 !important;
}
::v-deep .colrow {
    background-color: #c0ffc0;
}
::v-deep .el-input.is-disabled .el-input__inner {
    color: #606266;
    cursor: default;
}
::v-deep .vxe-table .vxe-body--column.col-blue {
    color: blue;
}
::v-deep .vxe-table .vxe-body--column.col-red {
    color: red;
}
.fixtotal{
    overflow: hidden;
    position: absolute;
    left: 0px;
    bottom: 3%;
    z-index: 1;
    width: 100%;
}
</style>